package com.wty.emp.service;

import com.wty.commons.exception.InsertException;
import com.wty.commons.id.IdWorker;
import com.wty.emp.mapper.JobMapperWty;
import com.wty.emp.pojo.JobWty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author:wangtianyu
 * @Date：Created on 2020/4/21 0021 15:49
 */
@Service
public class JobServiceWty {

    @Autowired
    private JobMapperWty jobMapper;

    @Autowired
    private IdWorker idWorker;

    public JobWty addJob(JobWty job)throws Exception {
        Long id = idWorker.nextId();
        job.setJobid(id);
        int count = jobMapper.insert(job);
        if (count == 0) {
            throw new InsertException("插入Job失败");
        }
        return job;
    }
}
